package com.test.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class LoginController {
    @RequestMapping("/login")
    public String login(HttpSession session, @RequestParam("username") String username, @RequestParam("password") String password){
        // 把用户的信息存入session
        session.setAttribute("userLoginInfo",username);
        return "home";
    }
    @RequestMapping("/logout")
    public String logout(HttpSession session){
        //session.invalidate();  //销毁session
        session.removeAttribute("userLoginInfo");
        return "redirect:/index";
    }
}
